#ifndef SERVICE_EVENT_H_INCL
#define SERVICE_EVENT_H_INCL

#if __GNUC__ > 3 || _MSC_VER > 1020
#pragma once
#endif

#ifndef __cplusplus
#error this header requires C++ compiler
#endif

//namespace broadcast
//{
//
// service event and listener definitions
//
enum service_event_type
{
    SERVICE_BASE = 0,
    SERVICE_ERROR = 127,
};

enum service_error_type
{
    SERVICE_ERROR_BASE = 0U,
    SERVICE_ERROR_UNKNOWN = ~0U,
};

// base event
struct service_event
{
    service_event(unsigned int a_which)
            : which(a_which)
    {
    }

    unsigned int which;
};

// error event
struct service_error_event: service_event
{
    service_error_event(service_error_type a_what, int a_extra = 0)
            : service_event(SERVICE_ERROR),
            what(a_what),
            extra(a_extra)
    {
    }

    service_error_type what;
    int extra;
};

// all event will be sent by this callback
typedef void (*service_listener_f)(service_event * event,
                                   void *cookie);

//}                             // end of namespace broadcast

#endif                          // end of #ifndef SERVICE_EVENT_H_INCL
